package com.platform.api.bzproject.job;

import com.platform.api.common.service.ByteService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;

import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.io.IOException;

/**
 * @author guoyunfei on 2021/12/5 19:08
 * @className MiniAccessToken
 * @description TODO  小程序token定时任务
 * @Version 1.0
 */
@Slf4j
@Component
public class MiniAccessTokenJob {

    @Autowired
    private ByteService byteService;

    @Value("${spring.profiles.active}")
    private String active;

    @Async
    @Scheduled(cron = "0 0/50 * * * ?")
    //@Scheduled(cron = "0/30 * * * * ?") //或直接指定时间间隔，例如：5秒
    public void getAccessToken() throws IOException {
        if("dev".equals(active)){
            return;
        }
        byteService.getAccessToken();
        log.info("执行了byteService.getAccessToken();");
    }

}
